﻿using Api.WDS.Operate;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Api.WDS.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SearchController : ControllerBase
    {
        /// <summary>
        /// 实时搜索
        /// </summary>
        /// <returns></returns>
        [HttpGet("Real")]
        public IActionResult Real()
        {
            var text = HttpContext.Request.Query["LikeText"];

            return Ok(new SearchOp().RealLikeText(text));
        }

        [HttpGet("InsertHeat")]
        public IActionResult InsertHeat()
        {
            var text = HttpContext.Request.Query["LikeText"];

            return Ok(new SearchOp().InsertHeat(text));
        }

        [HttpGet("Find")]
        public IActionResult Find()
        {
            var token = HttpContext.Request.Query["Token"];
            var text = HttpContext.Request.Query["LikeText"];
            var userCount = HttpContext.Request.Query["UserCount"];
            var articleCount = HttpContext.Request.Query["ArticleCount"];

            return Ok(new SearchOp().FindResult(token, userCount, articleCount, text));
        }
    }
}
